<template>
  <div class="approvalnode">
    <div class="approvalnode_top">
      <div class="approvalnode_top_name">
        审批
      </div>
      <div class="approvalnode_top_content">
        <nodeGroup v-bind="$attrs" />
      </div>
    </div>
    <div class="approvalnode_bottom">
      <div class="approvalnode_bottom_name">
        审批通用规则
      </div>
      <div>
        <el-form ref="form" :model="form" label-width="150px">
          <el-form-item label="自动跳过低级角色">
            <el-switch
              v-model="form.isAbove"
              :active-value="1"
              :inactive-value="0"
              @change="skipChange"
            />
          </el-form-item>

        </el-form></div>
    </div>
  </div>

</template>

<script>
import nodeGroup from './auditNodeComponent.vue'
export default {
  components: {
    nodeGroup

  },
  props: {
    isAbove: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {
      form: {
        isAbove: 1
      }
    }
  },
  watch: {
    isAbove(newval) {
      this.form.isAbove = this.isAbove
    }
  },
  created() {
    if (JSON.parse(localStorage.getItem('setAuditnode'))) {
      console.log('setAuditnode', JSON.parse(localStorage.getItem('setAuditnode')))
    } else {
      const setAuditnode = [{
        id: 0,
        icon: '+',
        sevent: 'addstep',
        content: '添加新节点'
      }]
      localStorage.setItem('setAuditnode', JSON.stringify(setAuditnode))
    }
  },
  methods: {
    // 自动跳过低级
    skipChange(val) {
      localStorage.setItem('setSkip', JSON.stringify(val))
    }
  }
}
</script>

<style lang="scss" scoped>
.approvalnode{
  padding: 10px;
  box-sizing: border-box;
  &_top{
    &_name{
      font-size: 16px;
      font-weight: 600;
    }
    &_content{
      margin-top: 70px;
      padding: 15px;
      box-sizing: border-box;
    }

  }
    &_bottom{
      margin-top: 50px;
    &_name{
      font-size: 16px;
      font-weight: 600;

    }
  }
}
</style>
